Skip to content

fix: cancel sandbox proxy iframe timeout on effect cleanup to prevent StrictMode unhandled rejection#190

Merged
idosal merged 4 commits intoMCP-UI-Org:mainfrom
matsjfunke:main
May 9, 2026
Merged

fix: cancel sandbox proxy iframe timeout on effect cleanup to prevent StrictMode unhandled rejection#190
idosal merged 4 commits intoMCP-UI-Org:mainfrom
matsjfunke:main

Conversation

@matsjfunke
Copy link
Copy Markdown
Contributor

@matsjfunke matsjfunke commented Apr 7, 2026

This adresses the issue with react strictmode mentioned in the Issue I raised

… StrictMode unhandled rejection

Co-authored-by: claude <noreply@anthropic.com>
@matsjfunke
Copy link
Copy Markdown
Contributor Author

matsjfunke commented Apr 20, 2026

@idosal hey wanted to check on this, is any chance we can merge this so I can stop using a patched version?

@matsjfunke
Copy link
Copy Markdown
Contributor Author

@idosal hey wanted to check on this, is any chance we can merge this so I can stop using a patched version?

@aharvard what do you think can this tiny thing go in?

@idosal
Copy link
Copy Markdown
Collaborator

idosal commented Apr 23, 2026

@idosal hey wanted to check on this, is any chance we can merge this so I can stop using a patched version?

Sorry @matsjfunke , completely missed this PR. I'll go over it tomorrow.

@evanrasmussen9
Copy link
Copy Markdown

@idosal Hey I'm just following up here to see if this can be merged in at some point?

CC: @matsjfunke

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses React StrictMode effect double-invocation in the TypeScript client by adding a cancellation mechanism so sandbox iframe readiness timeouts can be cleared during effect cleanup, preventing later unhandled rejections.

Changes:

  • Extend setupSandboxProxyIframe to accept an optional mutable cancel ref that can clear the pending timeout/listeners.
  • Wire the cancel ref into AppFrame’s effect cleanup to cancel in-flight sandbox setup during teardown.
  • Update AppFrame tests and add a lifecycle test covering the StrictMode cleanup timing scenario.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sdks/typescript/client/src/utils/app-host-utils.ts Adds SandboxCancelRef and exposes a synchronous cancellation hook for the sandbox iframe readiness flow.
sdks/typescript/client/src/components/AppFrame.tsx Creates/passes a cancel ref into iframe setup and invokes it during effect cleanup.
sdks/typescript/client/src/components/__tests__/AppFrame.test.tsx Updates expectations for the new function signature and adds a StrictMode-oriented lifecycle test.

Comment thread sdks/typescript/client/src/utils/app-host-utils.ts Outdated
@matsjfunke
Copy link
Copy Markdown
Contributor Author

tests now:
Screenshot 2026-05-08 at 21 00 58

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@idosal idosal merged commit ce5893e into MCP-UI-Org:main May 9, 2026
12 checks passed
@idosal
Copy link
Copy Markdown
Collaborator

idosal commented May 9, 2026

Thanks for the contribution @matsjfunke, truly appreciated!

github-actions Bot pushed a commit that referenced this pull request May 9, 2026
…v7.1.1) (2026-05-09)

### Bug Fixes

* cancel sandbox proxy iframe timeout on effect cleanup to prevent StrictMode unhandled rejection ([#190](#190)) ([ce5893e](ce5893e))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

🎉 This PR is included in version 7.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants